/**
 * Handle click event in buttons to change
 */
 $("#planning-status-form button").die('click').live('click', function(event) {	
    
    var $form = $("#planning-status-form");
    
	var name = $(this).attr('name');
	var value = $(this).val();

	if (name === "stop-planning" ) {
		$form.submit();	
	}
	else {       
    	var url = $form.attr('action');
	
		var formData = $form.closest('form').serializeArray();
  		formData.push({ name: name, value: value });
	
   		$.ajax({
   			url: url,
 			type: "POST",
 			data: formData,
 			dataType: "HTML",
  			success: function(data){
	  			var $form = $("#planning-status-form");
    			$form.empty();
    			$form.append(data);
   			}
 		});
 	
	 	return false;		
	}
});